import {createRouter, createWebHistory} from "vue-router";
import login from "../views/login.vue";

const routes = [
    {
        path: "/",
        redirect: "/login",
        meta: {
            title: "登录",
        },
    },
    {
        path: "/login",
        name: "login",
        component: login,
        meta: {
            title: "登录",
        },
    },
    {
        path: "/home",
        name: "home",
        component: () => import("../views/Home v2.vue"),
        // component: () => import("../views/Home.vue"),
        redirect: "/home/orginfo",
        children: [
            {
                path: '/home/homeShow',
                name: 'home',
                component: () => import("../views/home/homeShow/homeShow.vue")
            },
            // 系统管理
            {
                path: "/home/orginfo", //组织机构
                name: "organization",
                component: () =>
                    import("../views/SystemAdmin/OrganiZation/OrganiZation.vue"),
            },
            {
                path: "/home/sysuser", //系统用户
                name: "userinfo",
                component: () => import("../views/SystemAdmin/UserInfo/UserInfo.vue"),
            },
            {
                path: "/home/onlineuser", //在线用户
                name: "onlineinfo",
                component: () => import("../views/SystemAdmin/OnlineUser/index.vue"),
            },
            {
                path: "/home/empinfo", //职员信息
                name: "empinfo",
                component: () => import("../views/SystemAdmin/EmpInfo/index.vue"),
            },
            {
                path: "/home/sysrole", //系统角色
                name: "sysrole",
                component: () => import("../views/SystemAdmin/SysRole/index.vue"),
            },
            {
                path: "/home/syslog", //操作日志
                name: "loginfo",
                component: () => import("../views/SystemAdmin/LogInfo"),
            },
            {
                path: "/home/basedic", //字典类别
                name: "category",
                component: () => import("../views/InforMation/CateGory.vue"),
            },
            {
                path: "/home/messagedic", //字典信息
                name: "message",
                component: () => import("../views/InforMation/MessAge1.vue"),
            },
            {
                path: "/home/parameter", //参数信息
                name: "parameter",
                component: () =>
                    import("../views/InforMation/parameters/ParaMeter.vue"),
            },
            {
                path: "/home/receiptsnature", //单据性质
                name: "receiptsnature",
                component: () =>
                    import("../views/InforMation/ReceiptsNature/ReceiptsNature.vue"),
            },
            {
                path: "/home/productclassify", //产品分类
                name: "productclassify",
                component: () =>
                    import("../views/InforMation/ProductClassify/ProductClassify.vue"),
            },
            {
                path: "/home/warehouse", //仓库信息
                name: "warehouse",
                component: () =>
                    import("../views/InforMation/WarehouseInfo/WarehouseInfo.vue"),
            },

            {
                path: "/home/equipment", //装备信息
                name: "equipment",
                component: () => import("../views/InforMation/EquipMent/EquipMent.vue"),
            },
            {
                path: "/home/meterial", //器材信息
                name: "meterial",
                component: () => import("../views/InforMation/MeteriAl/MeteriAl.vue"),
            },
            {
                path: "/home/machinetool", //机工具设备
                name: "machinetool",
                component: () =>
                    import("../views/InforMation/MachineTool/MachineTool.vue"),
            },
            {
                path: "/home/establish",
                name: "establish",
                component: () => import("../views/InforMation/EstabLish/EstabLish.vue"),
            },
            {
                path: "/home/NoticeOfShipment",		//销售发货通知管理
                name: "NoticeOfShipment",
                component: () => import("../views/SalesManagement/NoticeOfShipment/NoticeOfShipment.vue"),
            },
            {
                path: "/home/saleso",		//销售单
                name: "SaleOrder",
                component: () => import("../views/SalesManagement/NoticeOfShipment/SaleOrder.vue"),
            },
            {
                path: '/home/ShipmentScan',		//销售发货扫描管理
                name: 'ShipmentScan',
                component: () => import("../views/SalesManagement/ShipmentScan/ShipmentScan.vue")
            },
            {
                path: '/home/probar',		//产品序号维护
                name: 'ProductSerialNumber',
                component: () => import("../views/ProductionManagement/ProductSerialNumber/ProductSerialNumber.vue")
            },
            {
                path: '/home/proinv',		//物料维护
                name: 'WorkOrdermaintenance',
                component: () => import("../views/ProductionManagement/WorkOrdermaintenance/WorkOrdermaintenance.vue")
            },
            {
                path: '/home/promor',		//工序维护
                name: 'ProcessMaintenance',
                component: () => import("../views/ProductionManagement/ProcessMaintenance/ProcessMaintenance.vue")
            },
            {
                path: '/home/prowork',		//工序维护
                name: 'ProcessManagement',
                // component: () => import("../views/ProductionManagement/ProcessManagement/ProcessManagement.vue")
                component: () => import("../views/ProductionManagement/ProcessManagement/ProcessManagement v2.vue")
            },
            {
                path: '/home/procheck',		//质检管理
                name: 'QualityControl',
                component: () => import("../views/ProductionManagement/QualityControl/QualityControl.vue")
            },
            {
                path: '/home/protest',		//质检管理
                name: 'test',
                component: () => import("../views/ProductionManagement/test/test.vue")
            },
            {
                path: '/home/procra',		//工艺维护管理
                name: 'ProcessMaintenanceManagement',
                component: () => import("../views/ProductionManagement/ProcessMaintenanceManagement/ProcessMaintenanceManagement.vue")
            },
            {
                path: '/home/PackAndStore',		//包装入库
                name: 'PackAndStore',
                component: () => import("../views/ProductionManagement/PackAndStore/PackAndStore.vue")
            },
            {
                path: '/home/basewpc',
                name: 'Process',
                component: () => import("../views/InforMation/Process/Process.vue")
            },
            {
                path: '/home/basewsc',
                name: 'Works',
                component: () => import("../views/InforMation/Works/Works.vue")
            },
            // {
            //     path: '/home/puravc',
            //     name: 'Delivery',
            //     component: () => import("../views/Procurement/Delivery/Delivery.vue")
            // },
            {
                path: "/home/purhis",
                name: "历史到货单",
                component: () => import("@/views/Procurement/Historical/Historical.vue"),
            },
            {
                path: "/home/puravc",
                name: "到货单扫描",
                component: () => import("@/views/Procurement/scan/scan.vue"),
            },
            {
                path: "/home/chatbar",
                name: "任务令产品编码状态",
                component: () => import("@/views/TaskOrder/TaskCode.vue"),
            },
            {
                path: "/home/chatwork",
                name: "任务令产品编码工序状态",
                component: () => import("@/views/TaskOrder/TaskWork.vue"),
            },
            {
                path: "/home/chatinv",
                name: "任务令产品材料序列号",
                component: () => import("@/views/TaskOrder/TaskSerial.vue"),
            },
            {
                path: "/home/oo",
                name: "销售出库单",
                component: () => import("@/views/TaskOrder/oo.vue"),
            },
            {
                path: "/home/qe",
                name: "质检数据",
                component: () => import("@/views/TaskOrder/qe.vue"),
            },
            {
                path: "/home/sde",
                name: "发货数据",
                component: () => import("@/views/TaskOrder/sde.vue"),
            },
            {
                path: "/home/demo",
                name: "测试",
                component: () => import("@/views/demo.vue"),
            }
        ],
    },
];

const router = createRouter({
    history: createWebHistory(process.env.BASE_URL),
    routes,
});
// 路由守卫
// 验证token，只有存在token的时候，才能跳转到内容页
// router.beforeEach((to, from, next) => {
//   let token = sessionStorage.getItem("token");
//   if (token || to.path === "/login") {
//     next();
//   } else {
//     next({ path: "/login"});
//   }
// });
// router.beforeEach(async (to, from, next) => {
//   NProgress.start();
//   // document.title = utils.getPageTitle(to.meta.title);
//   if (utils.isEmpty(from.name) && router.getRoutes().length <= 5 && store.getters.islogin && store.getters.routes.length > 0) {
//     await store.dispatch("permission/setMenuList").then(() => next({ path: to.path }));
//   } else {
//     if (to.matched.some(p => p.meta.auth)) {
//       if (store.getters.islogin !== true || utils.isEmpty(store.getters.token)) {
//         await store.dispatch("system/resetToken").then(() => {
//           next({ path: "/login", query: { redirect: to.fullPath } });
//         });
//       } else next();
//     } else next();
//   }
// });
// router.beforeEach( (to,from,next)=>{
//   if()
// } )

export default router;
